package com.prj.ufdm.demo.tutorial.annotation;

import java.lang.annotation.Annotation;

/**
 * 注解应用
 * @author Administrator
 *
 */
public class AnnotationDemo {

	public static void main(String[] args) throws Exception {
		// 通过反射获取注解值
		Class c = Class.forName("com.prj.ufdm.demo.tutorial.annotation.UserInfo");
		Annotation[] annotations = c.getAnnotations();
		for(Annotation annobj : annotations) {
			// 判读是否为 DefUserAnnotation 的注解
			if(c.isAnnotationPresent(DefAnnotation.class)) {
				DefAnnotation defUserAnnotation  = (DefAnnotation)annobj;
				System.out.println(defUserAnnotation.name());
				System.out.println(defUserAnnotation.sex());
			}
		}
	}

}
